package cn.dao.Impl;

import cn.base.Impl.IBaseDaoImpl;
import cn.domain.User;
import cn.dao.UserDao;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by jiaxiang Huang on 2017/3/9.
 */
@Repository
public class UserDaoImpl extends IBaseDaoImpl<User> implements UserDao {
    @Override
    public List<User> getUserName(String userName) {
        String hql="from User where userName=?";
        return session().createQuery(hql).setParameter(0,userName).list();
    }

    @Override
    public User username(String userName,String password) {
        User user=new User();
        String hql="from User where userName=? and password=?";
        List<User> list=session().createQuery(hql).setParameter(0,userName).setParameter(1,password).list();
        if(list!=null&&list.size()>0){
            user=list.get(0);
            return user;
        }
        return null;
    }
}
